vue学习 32路由精讲之二级路由和三级路由

本文深入探讨Vue路由的配置,包括如何设置二级和三级路由。通过在main.js中配置路由,并在路由对象数组中利用`redirect`属性指定默认打开的子级路由。同时,介绍在子级路由中使用`children`属性,其值为包含多个路由对象的数组,以此实现多级路由结构。
摘要由CSDN通过智能技术生成

分级时,默认打开指定下级的路由,使用redirect属性,其值为子级路由的路径path.

子级使用属性children: 值为数组,数组中每个元素都是一个路由对象

二级路由

在main.js中配置路由

// 二级路由
import Contact from './components/about/Contact'
import Delivery from './components/about/Delivery'
import History from './components/about/History'
import OrderingGuide from './components/about/OrderingGuide'

在routes中,(routes是由每一个路由对象组成的数组)

{
		path: '/about',
		name: 'aboutLink',
		component: About,
		redirect: '/about/contact',
		children: [{
				path: '/about/contact',
				name: "contactLink",
				component: Contact,
				redirect: '/personname',
				children: [{
						path: '/phone',
						name: "phoneNumber",
						component: Phone
					},
					{
						path: '/personname'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值